<!-- 举报表单 -->
<template>
	<benben-popup
		v-model="isShow"
		:mask="true"
		:mask-close-able="false"
		mode='center'
		z-index="99"
	>
		<view class="flex benben-flex-layout flex-wrap align-center">
			<view class='flex flex-direction flex-wrap align-center'>
				<view class='flex flex-direction align-center simplifiedPaper_fd1_0_c0'>
					<text class='simplifiedPaper_fd1_0_c0_c0'>举报</text>

					<view class="flex flex-wrap align-center">
						<view
							class="item_box"
							:class="{cur:item.aid == sId}"
							v-for="item in typeList"
							:key="item.aid"
							@click="sId=item.aid"
						>{{item.name}}</view>
					</view>

					<view class='flex flex-wrap align-center simplifiedPaper_fd1_0_c0_c2'>
						<view
							class='flex flex-wrap align-center justify-center simplifiedPaper_fd1_0_c0_c2_c0'
							@click.stop="isShow=false"
						>
							<text class='simplifiedPaper_fd1_0_c0_c2_c0_c0'>取消</text>
						</view>
						<button
							:loading="submitLoading"
							class='flex flex-wrap align-center justify-center simplifiedPaper_fd1_0_c0_c2_c1'
							@click.stop="submit"
						>
							<text class='simplifiedPaper_fd1_0_c0_c2_c0_c0'>立即举报</text>
						</button>
					</view>
				</view>
				<image
					class='simplifiedPaper_fd1_0_c1'
					mode="aspectFit"
					:src='STATIC_URL+"74.png"'
					@click.stop="isShow=false"
				></image>
			</view>
		</view>
	</benben-popup>
</template>

<script>
	/**
	 * @event {Function} open 打开弹窗显示
	 */
	export default {
		data() {
			return {
				isShow: false,
				typeList: [],
				sId: "",
				pageData: {},
				submitLoading: false,
			}
		},
		created() {
			// 获取举报类型
			this.$post("656f124e1cb07").then(res => this.typeList = res.data || [])
		},
		methods: {
			open(info = {}) {
				console.log("打开举报弹窗");
				this.isShow = true;
				this.pageData = info;
			},
			async submit() {
				console.log("提交举报申请");
				if (this.submitLoading) return;
				if (!this.sId) return this.$msg("请选择举报原因")
				this.submitLoading = true;
				try {
					const res = await this.$post('656f12b668387', {
						type: this.pageData.isWanneng ? 1 : 2,
						record_id: this.pageData.record_id,
						report_type_id: this.sId,
					});
					this.isShow = false;
					this.sId = "";
					this.$msg(res.msg || "举报成功")
				} catch (e) { this.$msg(e?.msg || "举报失败") }
				this.submitLoading = false;
			},
		}
	}
</script>

<style
	lang="scss"
	scoped
>
	@import './../digitalPersonUseMessage.scss';

	.simplifiedPaper_fd1_0_c0 {
		height: auto;
		max-height: 60vh;
	}

	.item_box {
		background-color: #ffffff99;
		color: #fff;
		padding: 0 24rpx;
		height: 50rpx;
		border-radius: 25rpx;
		font-size: 30rpx;
		box-sizing: border-box;
		border: 1px solid #ffffff99;
		margin: 0 24rpx 24rpx 0;

		&.cur {
			color: #47efe2;
			border-color: #47efe2;
			background-color: transparent;
		}
	}
</style>